home *** CD-ROM | disk | FTP | other *** search
- program Launcher;
-
- uses
- WinTypes, WinProcs, IniFiles, SysUtils;
-
- {$R *.RES}
-
- {$DEFINE NewEngineLayout}
- { Define the above if this is based on the new engine layout }
-
-
- Const
- cProductIdFileName = 'ID921416.ID_'; { !!! MUST match PRODUCT_ID_FILENAME in CUSTOM.RUL !!! }
- cProgramKeyName = '92141-6'; { !!! MUST match APP_UPC_CODE in CUSTOM.RUL !!! }
- cSectionName = 'Sofsource'; { !!! MUST match PROGRAM_FOLDER_NAME in CUSTOM.RUL !!! }
- {$IFDEF NewEngineLayout}
- BinarySetName = 'SET001\';
- {$ENDIF}
-
- cPermanentSetupLog = 'SOF_LOG_.INI'; { Don't change this value }
-
- const
- DosDelimSet : set of Char = ['\', ':', #0];
-
-
- Var
- IniLog : TIniFile;
- FileToFind,
- RecordedDestination : String;
-
-
-
- Function AddBackSlash( Const DirName : String ) : String;
- { Add a default backslash to a directory name }
- Begin
-
- If DirName[ Length(DirName) ] in DosDelimSet Then
- AddBackSlash := DirName
- ELSE
- AddBackSlash := DirName + '\';
-
- End; { Function AddBackSlash }
-
-
-
- Function JustPathname( Const PathName : String ) : String;
- { Return just the drive:directory portion of a pathname }
- Var
- I : Word;
- Begin
-
- I := Succ( Word( Length(PathName) ) );
- Repeat
- Dec(I);
- Until (PathName[I] in DosDelimSet) or (I = 0);
-
- If I = 0 Then { Had no drive or directory name }
- JustPathname[0] := #0
- ELSE
- If I = 1 Then { Either the root directory of default drive or invalid pathname }
- JustPathname := PathName[1]
- ELSE
- If (PathName[I] = '\') Then
- Begin
- If PathName[Pred(I)] = ':' Then { Root directory of a drive, leave trailing backslash }
- JustPathname := Copy(PathName, 1, I)
- ELSE { Subdirectory, remove the trailing backslash }
- JustPathname := Copy(PathName, 1, Pred(I));
- End
- ELSE { Either the default directory of a drive or invalid pathname }
- JustPathname := Copy(PathName, 1, I);
-
- End; { Function JustPathName }
-
-
-
- Procedure LaunchSetup;
- Var
- FileToExecute : String;
- pFileToExecute : Array[0..254] of Char;
- Begin
-
- FileToExecute := AddBackSlash( JustPathName( ParamStr(0)) );
-
- ChDir( FileToExecute );
-
- FileToExecute := AddBackSlash( FileToExecute) + 'SETUP.EXE AUTOPLAY';
-
- StrPCopy( pFileToExecute, FileToExecute );
-
- If WinExec( pFileToExecute, sw_ShowNormal ) < 32 Then
- Begin
- MessageBeep( mb_IconHand );
- MessageBox( 0, 'Unable to launch "SETUP.EXE"', 'Error', 0 );
- End;
-
- End; { Procedure LaunchSetup }
-
-
- {$IFDEF NewEngineLayout}
- Function GetFileToFind( RecordedDest : String ) : String;
- Begin
- { Remove the last backslash }
- If Copy( RecordedDest, Length(RecordedDest), 1 ) = '\' Then
- Delete( RecordedDest, Length(RecordedDest), 1 );
- Result := JustPathName( RecordedDest );
- Result := AddBackSlash( Result ) + BinarySetName;
- End; { GetFileToFind }
- {$ENDIF}
-
- begin
-
- IniLog := TIniFile.Create( cPermanentSetupLog );
- RecordedDestination := IniLog.ReadString( cSectionName, cProgramKeyName, '' );
- IniLog.Free;
-
- If RecordedDestination = '' Then
- LaunchSetup
- ELSE
- Begin
- {$IFDEF NewEngineLayout}
- FileToFind := GetFileToFind( RecordedDestination ) + cProductIDFileName;
- {$ELSE}
- FileToFind := AddBackSlash( RecordedDestination ) + cProductIDFileName;
- {$ENDIF}
- If NOT FileExists( FileToFind ) Then
- LaunchSetup;
- End;
-
- end.
-